<html>
<head><meta charset="utf-8"><title>better symbol names · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html">better symbol names</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224169947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224169947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kimundi <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224169947">(Jan 27 2021 at 11:49)</a>:</h4>
<p>Hi, first time in a long while to try to use zulip, appologies if I'm posting this wrong.</p>
<p>Something I keep noticing when inspecting assembly is that certain symbols/labels end up with pretty generic or annonymous names. For example in this: <a href="https://godbolt.org/z/drYxdG">https://godbolt.org/z/drYxdG</a> All instances of the generic impl are named <code>&lt;T as ...</code> instead of <code>&lt;u8 as...</code> and <code>&lt;u16 as ...&gt;</code>. Similarily, all the generated vtables get annonymous names like <code>.L__unnamed_2</code> instead of for example <code>&lt;u8 as Trait&gt;::$vtable</code> or so.</p>
<p>I was wondering if this is something that can be improved on, or wether there are backwards compability or technological reasons why it can't.</p>



<a name="224173407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224173407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224173407">(Jan 27 2021 at 12:27)</a>:</h4>
<p>Have you tried -Zsymbol-mangling-version=v0? That intends to preserve generics and such much more precisely.</p>



<a name="224173612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224173612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224173612">(Jan 27 2021 at 12:29)</a>:</h4>
<p>For vtables the names are the way names are generated by LLVM for anonymous constants. The <code>.L</code> prefix ensures that the symbols get removed when linking.</p>



<a name="224174077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kimundi <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174077">(Jan 27 2021 at 12:34)</a>:</h4>
<p><code>-Zsymbol-mangling-version=v0</code> improves the situation for the impls, yeah. I'm not at the top of things development-wise - is that the old legacy naming, or a new unstable one?</p>



<a name="224174214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kimundi <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174214">(Jan 27 2021 at 12:36)</a>:</h4>
<p>So, for technically reasons the vtables can not be named differently? Or would, hypothetically, something like <code>.L&lt;X as Y&gt;::vtable</code> be doable?</p>



<a name="224174394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174394">(Jan 27 2021 at 12:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125789">Kimundi</span> <a href="#narrow/stream/131828-t-compiler/topic/better.20symbol.20names/near/224174077">said</a>:</p>
<blockquote>
<p><code>-Zsymbol-mangling-version=v0</code> improves the situation for the impls, yeah. I'm not at the top of things development-wise - is that the old legacy naming, or a new unstable one?</p>
</blockquote>
<p><code>v0</code> is the new unstable scheme</p>



<a name="224174496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kimundi <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174496">(Jan 27 2021 at 12:39)</a>:</h4>
<p>Alright, was not sure if the v0 implies that its the original one</p>



<a name="224174523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174523">(Jan 27 2021 at 12:39)</a>:</h4>
<p>Longer symbol names result in longer link times. In addition you have to be very careful to ensure that the vtable name is unique. In cg_clif I accidentally didn't guarantee this. It resulted in a crash for a certain program that took me a long time to debug. As it turns out that program was spawning threads in two locations and the vtable of the two closures just so happened to get the same name, so spawning a thread at one location used the closure of the second spawn location.</p>



<a name="224174867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/better%20symbol%20names/near/224174867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kimundi <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/better.20symbol.20names.html#224174867">(Jan 27 2021 at 12:43)</a>:</h4>
<p>Ah right, symbol names have compilation performance impact like that... (Though to this day I still don't understand how it can be significant, but I'll believe that it is).<br>
And sure, an collision-resistant naming scheme prevents bugs, though if that where the only reasons then a naming scheme that just combines the existing counter scheme with a helpful name would be equally safe.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>